package musicstore.web.rest;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import musicstore.biz.UserBiz;
import musicstore.entity.User;

@Controller
@RequestMapping("/user")
public class UserRestController {
	@Autowired
	private UserBiz userBiz;
	@RequestMapping("/check-username")
	public void  checkUsernameIsInUse(String username, 
			HttpServletResponse response) throws IOException{ 
			String flag;
			User user =userBiz.fetchUserByUsername(username);
			if(user!=null){
				flag = "true";
			}else{
				flag = "false";
			}
			 
			 response.getWriter().write(flag);
			 response.getWriter().flush();
			 response.getWriter().close();
			 } 
}
